package com.example.kami.test;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.catalina.connector.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.LinkedHashMap;


/**
 * @author liuhang
 * @description 携程采集
 * @date 2022/05/16
 */
@RestController
@RequestMapping("/xc")
public class XcController {
    Logger log = LoggerFactory.getLogger(XcController.class);

    @RequestMapping(value = "/v1/login")
    private String getResponse() {
        LinkedHashMap map = new LinkedHashMap();
        RestTemplate restTemplate = new RestTemplate();
        MultiValueMap<String, String> email = new LinkedMultiValueMap<String, String>();
        email.add("user", "16218386919");
        email.add("pwd", "123456");
        email.add("device", "b190b360b27e264c");
        ResponseEntity<String> response = restTemplate.postForEntity("http://cloud.bmob.cn/8ab26aa44b96b57b/login3", email, String.class);
        JSONObject jsonObject = JSONObject.parseObject(response.getBody());
        map.put("code", 20);
        map.put("data", jsonObject.getString("data"));
        map.put("msg", "success");
        map.put("date", "2023/05/20 18:56:17");
        return JSON.toJSONString(map);
    }
}
